home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / etc / init.d / bluetooth < prev    next >
Text File  |  2006-05-15  |  3KB  |  144 lines

  1. #!/sbin/runscript
  2. # Copyright 1999-2004 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez-utils/files/bluez-utils-2.22-init.d,v 1.1 2005/11/03 14:44:20 brix Exp $
  5.  
  6. UART_CONF="/etc/bluetooth/uart"
  7.  
  8. depend() {
  9.     after coldplug
  10. }
  11.  
  12. start_uarts() {
  13.     [ -f /usr/sbin/hciattach -a -f ${UART_CONF} ] || return
  14.     grep -v '^#' ${UART_CONF} | while read i; do
  15.         /usr/sbin/hciattach $i
  16.     done        
  17. }
  18.  
  19. stop_uarts() {
  20.     killall hciattach > /dev/null 2>&1
  21. }
  22.  
  23. start() {
  24.        ebegin "Starting Bluetooth"
  25.  
  26.     if [ "${HID2HCI_ENABLE}" = "true" -a -x /usr/sbin/hid2hci ]; then
  27.         ebegin "    Running hid2hci"
  28.         /usr/sbin/hid2hci -0 -q    #be quiet
  29.         /bin/sleep 1 # delay for hid's to be detected by hotplug
  30.         eend $?
  31.     fi
  32.  
  33.     if [ "${HCID_ENABLE}" = "true" -a -x /usr/sbin/hcid ]; then
  34.         if [ -f "${HCID_CONFIG}" ]; then
  35.             ebegin "    Starting hcid"
  36.             start-stop-daemon --start --quiet \
  37.                 --exec /usr/sbin/hcid -- -f $HCID_CONFIG
  38.             eend $?
  39.         else
  40.             ewarn "Not enabling hcid because HCID_CONFIG is missing."
  41.         fi
  42.     fi
  43.     
  44.  
  45.     if [ "${SDPD_ENABLE}" = "true" -a -x /usr/sbin/sdpd ]; then
  46.         ebegin "    Starting sdpd"
  47.         start-stop-daemon --start --quiet --exec /usr/sbin/sdpd
  48.         eend $?
  49.     fi
  50.  
  51.     
  52.     if [ "${HIDD_ENABLE}" = "true" -a -x /usr/bin/hidd ]; then
  53.         ebegin "    Starting hidd"
  54.         start-stop-daemon --start --quiet \
  55.             --exec /usr/bin/hidd -- ${HIDD_OPTIONS} --server
  56.         eend $?
  57.     fi
  58.  
  59.     if [ "${RFCOMM_ENABLE}" = "true" -a -x /usr/bin/rfcomm ]; then
  60.         if [ -f "${RFCOMM_CONFIG}" ]; then
  61.             ebegin "    Starting rfcomm"
  62.             /usr/bin/rfcomm -f ${RFCOMM_CONFIG} bind all
  63.             eend $?
  64.         else
  65.             ewarn "Not enabling rfcomm because RFCOMM_CONFIG does not exists"
  66.         fi
  67.     fi
  68.  
  69.     if [ "${DUND_ENABLE}" = "true" -a -x /usr/bin/dund ]; then
  70.         if [ -n "${DUND_OPTIONS}" ]; then
  71.             ebegin "    Starting dund"
  72.             start-stop-daemon --start --quiet \
  73.                 --exec /usr/bin/dund -- ${DUND_OPTIONS}
  74.             eend $?
  75.         else
  76.             ewarn "Not starting dund because DUND_OPTIONS not defined."
  77.         fi
  78.     fi
  79.  
  80.     if [ "${PAND_ENABLE}" = "true" -a -x /usr/bin/pand ]; then
  81.         if [ -n "${PAND_OPTIONS}" ]; then
  82.             ebegin "    Starting pand"
  83.             start-stop-daemon --start --quiet \
  84.                 --exec /usr/bin/pand -- ${PAND_OPTIONS}
  85.             eend $?
  86.         else
  87.             ewarn "Not starting pand because PAND_OPTIONS not defined."
  88.         fi
  89.     fi
  90.  
  91.     start_uarts
  92.     eend 0
  93. }
  94.     
  95. stop() {
  96.     ebegin "Shutting down Bluetooth"
  97.  
  98.  
  99.     if [ "${PAND_ENABLE}" = "true" -a -x /usr/bin/pand ]; then
  100.         ebegin "    Stopping pand"
  101.         start-stop-daemon --stop --quiet --exec /usr/bin/pand
  102.         eend $?
  103.     fi
  104.  
  105.     if [ "${DUND_ENABLE}" = "true" -a -x /usr/bin/dund ]; then
  106.         ebegin "    Stopping dund"
  107.         start-stop-daemon --stop --quiet --exec /usr/bin/dund
  108.         eend $?
  109.     fi
  110.  
  111.     if [ "${RFCOMM_ENABLE}" = "true" -a -x /usr/bin/rfcomm ]; then
  112.         ebegin "    Stopping rfcomm"
  113.         /usr/bin/rfcomm release all
  114.         eend $?
  115.     fi
  116.  
  117.     if [ "${HIDD_ENABLE}" = "true" -a -x /usr/bin/hidd ]; then
  118.         ebegin "    Stopping hidd"
  119.         start-stop-daemon --stop --quiet --exec /usr/bin/hidd
  120.         eend $?    
  121.     fi
  122.  
  123.  
  124.     if [ "${SDPD_ENABLE}" = "true" -a -x /usr/sbin/sdpd ]; then
  125.         ebegin "    Stopping sdpd"
  126.         start-stop-daemon --stop --quiet --exec /usr/sbin/sdpd
  127.         eend $?
  128.     fi
  129.  
  130.     if [ "${HCID_ENABLE}" = "true" -a -x /usr/sbin/hcid ]; then
  131.         ebegin "    Stopping hcid"
  132.         start-stop-daemon --stop --quiet --exec /usr/sbin/hcid
  133.         eend $?
  134.     fi
  135.         
  136.     stop_uarts
  137.     eend 0
  138. }
  139.  
  140. restart() {
  141.     svc_stop
  142.     svc_start
  143. }
  144.